<%@page import="bll.CommonBll"%>
<%@ page language="java" contentType="text/html; charset=UTF-8"
	pageEncoding="UTF-8"%>
<!DOCTYPE html PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN" "http://www.w3.org/TR/html4/loose.dtd">

<%@page import="util.*"%>
<%@page import="dal.*"%>
<%@ page import="model.*,java.util.*"%>
<%
	int id = MiscUtil.getIntUrlParam(request, "id");
	ChecklistModel checklist = CommonBll.loadFullChecklist(id);
	boolean embedded = MiscUtil.getBoolUrlParam(request, "embedded");

	String[] trStyles = new String[] { "style=\"font-weight: bold; font-size:110%;background-color: #F7F2F2;\"",
			"style=\"font-weight: bold;\"", "", "", "", "" };
	String[] tdStyles = new String[] { "", "",
			"style=\"padding-left: 15px;\"",
			"style=\"padding-left: 30px; font-style: italic; \"", "style=\"padding-left: 45px; font-style: italic; \"" };
	
	String checklistName = checklist.getName();
	String checklistListUrl = "checklistList.jsp?idProject=" + checklist.getIdProject();

	String projectName = CacheUtil.getProjectName(checklist.getIdProject());
	String projectUrl = "project.jsp?id=" + checklist.getIdProject();
	
	List<ChecklistItemModel> list = checklist.getItems();
	int size = list.size();
%>

<html>
<head>
<meta http-equiv="Content-Type" content="text/html; charset=UTF-8">
<title>Checklist Item List</title>

<%if(!embedded){ %>
		<link rel="stylesheet" href="css/jquery-ui-1.8.14.custom.css" type="text/css" />
		<link rel="stylesheet" href="css/themes/ui-lightness/jquery.ui.all.css" />
		<link rel="stylesheet" href="css/jquery-dialog.css" />
		
		<script language="javascript" type="text/javascript" src="js/jquery-1.6.1.js"></script>
		<script type="text/javascript" src="js/jquery-ui-1.8.14.custom.min.js"></script>
		<script language="javascript" type="text/javascript" src="js/common.js"></script>
	<%} %> 
<link rel="stylesheet" href="css/listForm.css" />
<link rel="stylesheet" href="css/common.css" />
<script language="javascript" type="text/javascript">
		$(document).ready(pageLoaded);
		function pageLoaded()
		{	
			initDeleteConfirmation();
		} 
	</script>

</head>
<body>
	<% if (!embedded) { %>
	<div class="divContainer">
		<jsp:include page="menu.jsp"></jsp:include>
		<div class="divNavigation">
			<span>
				<b>Project: <a id="link_project" name="link_project" href="<%=projectUrl %>"><%=projectName %></a></b>
				&gt;
				<b>Checklist: <%=checklistName %></b>
				<br/><br />
				<a style="font-weight: bold;" href="checklistItemNew.jsp?idChecklist=<%=id%>">Add New Checklist Item</a>
				<br />
				<a style="font-weight: bold;" href="<%=checklistListUrl %>">Go Up to Checklist List</a>
				<br />
			</span>
		</div>
	<% } %>				
	<div class="divListHeaderBar" style="vertical-align:  middle;"><span style="padding-top: 0px;">NUMBER OF AGENDAS: </span><%=size%></div>
		<table class="tblList">
			<tr class="tblListHeader">
				<th class="thListHeader" colspan="2"></th>
				<th class="thListHeader">No</th>
				<th class="thListHeader">Item</th>
				<th class="thListHeader">Phase</th>
				<th class="thListHeader">PIC</th>
				<th class="thListHeader">Status</th>
				<th class="thListHeader">From</th>
				<th class="thListHeader">To</th>
				<th class="thListHeader">Remark</th>
			</tr>
	
			<%
				if(checklist != null)
				for (ChecklistItemModel obj : checklist.getItems()) {
					int idEmployee = obj.getIdEmployee();
					int idCompany = obj.getIdCompany();
			%>
	
			<tr class="trListItem" <%=trStyles[obj.getLevel()]%>>
				<td class="tdListHref Edit">
					<a href="checklistItem?mode=edit&id=<%=obj.getId()%>">Edit</a><br/>
					<a class="hrefDelete" href="checklistItem?mode=delete&id=<%=obj.getId()%>&idChecklist=<%=obj.getIdChecklist()%>" onclick="confirmToDelete();">Delete</a>
				</td>
				<td class="tdListHref">
					<%
						if (obj.getIsGroup()) {
					%> <a href="checklistItemNew.jsp?idChecklist=<%=obj.getIdChecklist()%>&idParent=<%=obj.getId()%> ">Add sub-item</a> 
					<% } %>
				</td>
				<td class="tdList tdListText" style="text-align: center;"><%=obj.getDisplayIndexToString()%></td>
				<td class="tdList tdListText tdItemName" <%=tdStyles[obj.getLevel()]%>><%=obj.getNameToString()%></td>
				<td class="tdList tdListText"><%=CacheUtil.getPhaseName(obj.getIdPhase())%></td>
				<td class="tdList tdListInt"><%=obj.getPIC()%></td>
				<td class="tdList tdListInt"><%=StringUtil.getChecklistItemStatus(obj.getStatus())%></td>
				<td class="tdList tdListDateTime"><%=StringUtil.toDateString(obj.getStartTime())%></td>
				<td class="tdList tdListDateTime"><%=StringUtil.toDateString(obj.getEndTime())%></td>
				<td class="tdList tdListTextarea"><%=obj.getRemarkToString()%></td>
			</tr>
			<%
				}
			%>
		</table>
	<%if(!embedded){ %> </div> <%} %>
</body>
</html>